package com.huahua.api.controller.entertainment;

import com.huahua.api.entity.entertainment.param.NameAnalysisParam;
import com.huahua.api.service.entertainment.NameAnalysisService;
import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Lazy;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;

/**
 * 姓名分析控制器
 *
 * @author Huahua-Ai
 * @date 2025-08-25 15:35:00
 */
@RestController
@RequestMapping("/entertainment/nameAnalysis")
@RequiredArgsConstructor(onConstructor = @__(@Lazy))
public class NameAnalysisController {

    private final NameAnalysisService nameAnalysisService;

    /**
     * 分析姓名
     *
     * @param param 包含姓名、性别、出生年份的参数
     * @return 流式返回姓名分析结果（Markdown格式）
     */
    @PostMapping(value = "/analyze", produces = MediaType.TEXT_EVENT_STREAM_VALUE)
    public Flux<String> analyzeName(@RequestBody NameAnalysisParam param) {
        return nameAnalysisService.analyzeName(param);
    }
}
